﻿using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.DependencyInjection;

namespace Kz.Telegram.Bot.Infrastructure
{
    public static class ServiceLocator
    {
        public static IServiceProvider Instance { get; set; }

        public static IApplicationBuilder ApplicationBuilder { get; set; }

        public static void SetInstance(IServiceProvider service) => Instance = service;
        public static T GetRequiredService<T>() where T : notnull => Instance!.GetRequiredService<T>();
        public static T GetService<T>() where T : notnull => Instance!.GetService<T>()!;

    }
}
